<!DOCTYPE html>
<html th:dir="Itr" lang="en-US"
      xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta th:charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>K3Cloud | 零售报表</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../../static/build/css/app.min.css" th:href="${#fn.getStaticFile('/build/css/app.min.css')}">
    <link rel="stylesheet" href="../../static/lib/plugins/handsontable/handsontable.full.min.css" th:href="@{/lib/plugins/handsontable/handsontable.full.min.css}" type="text/css"/>
    <link rel="stylesheet" href="../../static/lib/plugins/bootstrap-daterangepicker/daterangepicker.css" th:href="@{/lib/plugins/bootstrap-daterangepicker/daterangepicker.css}" type="text/css" media="all"/>
    <link rel="stylesheet" href="../../static/dist/css/common.css" th:href="${#fn.getStaticFile('/dist/css/common.css')}">
    <script src="../../static/build/js/app.min.js" th:src="${#fn.getStaticFile('/build/js/app.min.js')}"></script>
    <script src="../../static/lib/plugins/bootstrap-daterangepicker/moment.js" th:src="${#fn.getStaticFile('/lib/plugins/bootstrap-daterangepicker/moment.js')}" type="text/javascript"></script>
    <script src="../../static/lib/plugins/bootstrap-daterangepicker/daterangepicker.js" th:src="${#fn.getStaticFile('/lib/plugins/bootstrap-daterangepicker/daterangepicker.js')}" type="text/javascript"></script>
    <script src="../../static/lib/plugins/handsontable/handsontable.full.min.js" th:src="${#fn.getStaticFile('/lib/plugins/handsontable/handsontable.full.min.js')}"></script>
    <script src="../../static/dist/js/common.js" th:src="${#fn.getStaticFile('/dist/js/common.js')}"></script>
    <script th:inline="javascript">
        $(document).ready(function () {
            $("#btnSubmit").click(function(){
                $("#btnSubmit").attr("disable",true);
                var monthStart = $("#monthStart").val();
                var monthEnd = $("#monthEnd").val();
                if(monthStart <= monthEnd){
                    $("#btnSubmit").attr("disable",false);
                    $("#inputForm").submit();
                }else{
                    alert("警告！开始时间大于结束时间，请重新选择时间！");
                    $("#btnSubmit").attr("disable",false);
                }
            });
            var data = [[${retailShopReport}]];
            var nestedHeader = [[${nestedHeader}]];
            if (data.length > 0) {
                var ht = new Handsontable(document.getElementById('grid'), {
                    data: data,
                    height: 650,
                    rowHeaders: true,
                    colHeaders: false,
                    readOnly:true,
                    currentRowClassName: 'currentRow',
                    currentColClassName: 'currentCol',
                    fixedColumnsLeft: 1,
                    contextMenu: true,
                    autoColumnSize:true,
                    nestedHeaders:nestedHeader,
                    stretchH: 'all',
                    hiddenColumns: true,
                    collapsibleColumns: true
                });
                ht.selectCell(5,5);
            }
            var monthStart = $("#monthStart").val();
            var monthEnd = $("#monthEnd").val();
            var companyName = $("#companyName").val();
            $("#export_1").click(function(){
                if(confirm("确认导出数据?")){
                    window.location.href = ctx + "cloud/retailShopReport/export?monthStart="+monthStart+"&monthEnd="+monthEnd+"&companyName="+companyName;
                }
            });
        });
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini " th:classappend="${#session.getAttribute('sidebarClass')}" th:with="pageCode='retailShopReport'">
    <div Class="wrapper">
    <div th:replace="fragment/layout :: header"></div>
    <!-- Left side column. contains the logo and sidebar -->
    <div th:replace="fragment/layout :: menu(activePageCode=${pageCode})"></div>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <section class="content">
            <ul th:replace="fragment/menuTab :: menuTab(activePageCode=${pageCode})"></ul>
            <div class="panel panel-info">
                <div class="panel-body">
                    <form class="form-inline pull-left" role="form" th:action="@{/cloud/retailShopReport/list}" method="get" id="inputForm">
                        <div class="form-group">
                            <label for="monthStart">开始月份</label>
                            <input type="text" id="monthStart" name="monthStart" readonly="readonly"  class="form-control monthpicker"  th:value="${monthStart}"  style="width:120px;"/>
                        </div>
                        <div class="form-group">
                            <label for="monthEnd">结束月份</label>
                            <input type="text" id="monthEnd" name="monthEnd" readonly="readonly"  class="form-control monthpicker"  th:value="${monthEnd}"  style="width:120px;"/>
                        </div>
                        <div class="form-group">
                            <label for="companyName">账套</label>
                            <select name="companyName" id="companyName" class="form-control" style="width:180px;">
                                <option th:value="null" th:text="请选择账套"></option>
                                <option th:each="item : ${retailCloud}" th:value="${item}" th:text="${item}" th:selected="${companyName==item}">cloud</option>
                            </select>
                        </div>
                        <button type="submit" class="btn btn-success">
                            <span class="glyphicon glyphicon-search"></span>搜索
                        </button>
                    </form>
                    <button class="btn btn-export pull-right btn-info" id="export_1">
                        <span class="glyphicon glyphicon-cloud-download"></span>导出
                    </button>
                </div>
                <div class="panel-body">
                    <div id="grid" style="margin-top:10px;"></div>
                </div>
            </div>
        </section>
    </div>
    <footer th:replace="fragment/layout :: footer"></footer>
</div>
</body>
</html>